import type { PageResult } from '#/api/base';

import { requestClient } from '#/api/request';

export namespace DepartmentApi {
  /** 岗位信息 */
  export interface Department {
    id?: number;
    companyId?: number;
    name: string;
    handler: number;
    handlerName: string;
    createTime: string;
    updateTime: string;
  }
}

/** 查询部门列表 */
export function getDepartmentList(params?: {
  companyId?: number;
  pageNum?: number;
  pageSize?: number;
}) {
  return requestClient.get<PageResult<DepartmentApi.Department>>(
    '/department/list',
    {
      params,
    },
  );
}

/** 查询部门详情 */
export function getDepartment(id: number) {
  return requestClient.get<DepartmentApi.Department>(
    `/department/info?id=${id}`,
  );
}

/** 新增部门 */
export function createDepartment(data: DepartmentApi.Department) {
  return requestClient.post('/department/create', data);
}

/** 修改部门 */
export function updateDepartment(data: DepartmentApi.Department) {
  return requestClient.put('/department/update', data);
}

/** 删除部门 */
export function deleteDepartment(id: number) {
  return requestClient.delete(`/department/delete?id=${id}`);
}
